package com.uenpay.im.weight;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.uenpay.im.R;
import com.uenpay.im.callback.IOnBottomDialogListener;

/**
 *
 * @author SL
 * @date 2014/8/9
 * @copyRight http://www.qiyunxin.com
 */
public class BottomDialog2 {

	public static void showBottomDialog(Context mContext, String pop_dialog_more_one_str,String btn_one_str,
			String btn_two_str,final int pop_dialog_more_one_color, final IOnBottomDialogListener btn_one_listener) {
		final Dialog dialog = new Dialog(mContext, R.style.pop_dialog);
		dialog.setContentView(R.layout.pop_dialog_more_noe);
		Window win = dialog.getWindow();
		win.setGravity(Gravity.BOTTOM);
		win.setWindowAnimations(R.style.dialogWindowAnim);
		dialog.setCanceledOnTouchOutside(true);
		dialog.show();
		win.setLayout(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
				android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
		TextView pop_dialog_more_one_tv = (TextView) dialog.findViewById(R.id.pop_dialog_more_one_tv);
		
		if (!TextUtils.isEmpty(pop_dialog_more_one_str)) {
			pop_dialog_more_one_tv.setText(pop_dialog_more_one_str);
		}
		if(pop_dialog_more_one_color != -1)
			pop_dialog_more_one_tv.setTextColor(pop_dialog_more_one_color);
		
		Button btn_one = (Button) dialog
				.findViewById(R.id.pop_dialog_more_one_btn1);
		
		if(!TextUtils.isEmpty(btn_one_str)){
			btn_one.setText(btn_one_str);
		}

		Button btn_two = (Button) dialog
				.findViewById(R.id.pop_dialog_more_one_btn2);
		
		if(!TextUtils.isEmpty(btn_two_str)){
			btn_two.setText(btn_two_str);
		}
		

		if (btn_one_listener != null) {
			btn_one.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					dialog.dismiss();
					btn_one_listener.onClicked();
				}
			});
		}
		
		btn_two.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dialog.dismiss();
			}
		});
	}

}
